<template>
	<view>
		<totalMask :show.sync="isShow" :showType="showType">
			<view class="nvue-flex">
				<view class="title-bg">
					<text class="title">商品列表</text>
				</view>
				
				<scroll-view scroll-y class="list" :show-scrollbar="false" @scrolltolower="onLoadMore">
					<view class="view">
						<block v-for="(item, index) in goods_list" :key="index">
							<view class="item" @click="onBuy(item)">
								<image class="file" :src="item.image"></image>
								
								<view class="right">
									<text class="goods-name">{{item.title}}</text>
									
									<view class="bottom">
										<view class="price-bg">
											<text class="symbol">¥</text>
											<text class="price">{{item.price}}</text>
										</view>
										
										<view class="buy">
											<text class="buy-title">立即购买</text>
										</view>
									</view>
								</view>
							</view>
						</block>
					</view>
				</scroll-view>
			</view>
		</totalMask>
	</view>
</template>

<script>
	import storage from "@/utils/storage";
	import st from "@/utils/showtoast.js";
	
	export default {
		data() {
			return {
				isShow: false,
				showType: 0,
				
				goods_list: []
			}
		},
		mounted() {
			/**
			 * 进入看播列表显示数据
			 */
			uni.$on("YHStartLook", () => {
				let list = storage.getLiveRoomInfo()['goods']
				this.goods_list = list
			})
			/**
			 * 安卓物理返回键
			 */
			uni.$on("onAndroidBackPress", () => {
				this.onDestroyed()
			})
			/**
			 * 显示页面
			 */
			uni.$on("YHShowGoods", () => {
				this.isShow = true
				this.showType = 10
			})
		},
		methods: {
			/**
			 * 销毁
			 */
			onDestroyed() {
				uni.$off("YHStartLook")
				uni.$off("YHShowGoods")
				uni.$off("onAndroidBackPress")
			},
			
			/**
			 * 立即购买
			 */
			onBuy(item) {
				uni.navigateTo({
					url: '/wNew/pages/detail?id=' + item.id
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.title-bg {
		width: 300rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin-bottom: 30rpx;
	}
	.title {
		color: #333;
		font-size: 32rpx;
	}
	
	.list {
		margin-top: 30rpx;
		width: 750rpx;
		overflow: hidden;
		height: 600rpx;
	}
	
	.view {
		width: 750rpx;
		display: flex;
		flex-direction: column;
		overflow: hidden;
	}
	
	.item {
		width: 750rpx;
		padding: 0 35rpx;
		margin-bottom: 45rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		overflow: hidden;
	}
	
	.file {
		width: 200rpx;
		height: 200rpx;
		border-radius: 20rpx;
		overflow: hidden;
	}
	
	.right {
		flex: 1;
		margin-left: 20rpx;
		min-height: 200rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	
	.goods-name {
		color: #333;
		font-size: 30rpx;
		lines: 2;
		text-overflow: ellipsis;
	}
	
	.bottom {
		width: 460rpx;
		display: flex;
		flex-direction: row;
		align-items: flex-end;
		justify-content: space-between;
		overflow: hidden;
	}
	
	.price-bg {
		display: flex;
		flex-direction: row;
		align-items: flex-end;
	}
	.symbol {
		margin-right: 5rpx;
		color:#fa3534;
		font-size: 27rpx;
	}
	.price {
		color:#fa3534;
		font-size: 40rpx;
	}
	
	
	.buy {
		width: 150rpx;
		height: 60rpx;
		background: $grad-color;
		border-radius: 30rpx;
		overflow: hidden;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}
	.buy-title {
		color: white;
		font-size: 28rpx;
	}
	
</style>